package org.example.myerp.service.serviceimpl;

import com.mycloud.api.pojo.ApiGoods;
import org.example.myerp.mapper.productDesign.productArchiveManagement.MakeHouseMapper;
import org.example.myerp.pojo.MakeHouse;
import org.example.myerp.pojo.PageMyself;
import org.example.myerp.service.MyFeginService;
import org.example.myerp.until.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@SuppressWarnings("all")
public class MyFeginServiceImpl  implements MyFeginService {
    @Autowired
    MakeHouseMapper makeHouseMapper;

    @Autowired
    RedisUtil redisUtil;

    @Override
    public PageMyself<MakeHouse> makeHousePagefindByPager(Integer pageSize, Integer pageNum) {
        Map params = new HashMap<String, Object>();
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        PageMyself<MakeHouse> page = new PageMyself<MakeHouse>();
        page.setPageNum(pageNum);
        page.setPageSize(pageSize);
        List<MakeHouse> lis = makeHouseMapper.makeHousePagefindByPager(params);
        page.setRows(lis);
        page.setTotal(makeHouseMapper.makeHousePagepageTotal());
        return page;
    }

    @Override
    public void updateInfoRepby(Integer product_id) {
        redisUtil.del("makeHouse"+"*");
        makeHouseMapper.updateInfoRepby(product_id);
    }

    @Override
    public PageMyself<ApiGoods> goodsfindByPager(Integer pageNum, Integer pageSize) {
        Map params = new HashMap<String, Object>();
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        PageMyself<ApiGoods> page = new PageMyself<ApiGoods>();
        page.setPageNum(pageNum);
        page.setPageSize(pageSize);
        List<ApiGoods> lis = makeHouseMapper.goodsfindByPager(params);
        page.setRows(lis);
        page.setTotal(makeHouseMapper.goodsPageTotal());
        return page;
    }

    @Override
    public PageMyself<ApiGoods> goodsfindByPagers(Integer pageNum, Integer pageSize) {
        Map params = new HashMap<String, Object>();
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        PageMyself<ApiGoods> page = new PageMyself<ApiGoods>();
        page.setPageNum(pageNum);
        page.setPageSize(pageSize);
        List<ApiGoods> lis = makeHouseMapper.goodsfindByPagers(params);
        page.setRows(lis);
        page.setTotal(makeHouseMapper.goodsPageTotals());
        return page;
    }

    @Override
    public List<ApiGoods> fanGoods(List<Integer> productId) {
        return makeHouseMapper.fanGoods(productId);
    }


}
